﻿using System.Web.Mvc;
using LogikBug.ModularMvc;
using LogikBug.ModularMvc.Navigation;
using LogikBug.ModularMvc.Registration;

namespace Test.Modules.Accounts.ClientBilling
{
	public class ClientBillingModule : VisualModule
	{
		public ClientBillingModule()
		{
			Name = "Client Billing";
			MenuDisplayOrder = 4;
		}

		#region ModuleBase Members

		protected override void Initialize(IRegistrationContext context)
		{
			context.Routes.MapRoute(
				this,
				"ClientBillingModuleDefaultRoute",
				"billing/{action}/{id}",
				new { controller = "account", action = "index", id = UrlParameter.Optional },
				new[] { "Test.Modules.Accounts.ClientBilling.Controllers" }
			);

			context.Routes.MapRoute(
				this,
				"ClientBillingAjaxRoute",
				"ajax/{action}/billing",
				new { controller = "ajax", action = "clientbillingsubnavigation" },
				new[] { "Test.Modules.Accounts.ClientBilling.Controllers" }
			);
		}

		#endregion

		#region VisualModuleBase Members

		public override MenuItemCollection GetMenu(ViewContext viewContext, MenuType menuType)
		{
			if (menuType == MenuType.Main)
			{
				var url = new UrlHelper(viewContext.RequestContext);

				return new MenuItemCollection
				{
					new MenuItem("#", "Account")
					{
						CssClass = "ddHeaderSubNav",
						Data = url.RouteUrl("ClientBillingAjaxRoute", new
						{
						    controller = "ajax",
							action = "clientbillingsubnavigation"
						})
					}
				};
			}

			return null;
		}

		#endregion
	}
}